package com.ruoyi.wechat.api;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

import com.ruoyi.wechat.domain.Banner;
import com.ruoyi.wechat.service.IBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 广告表Controller
 * 
 * @author ruoyi
 * @date 2024-10-08
 */
@RestController
@RequestMapping("/wechatt/banner")
public class WxBannerController extends BaseController
{
    @Autowired
    private IBannerService bannerService;

    /**
     * 查询广告表列表
     */
    @GetMapping("/list")
    public AjaxResult list(Banner banner)
    {
//        startPage();
        List<Banner> list = bannerService.selectBannerList(banner);
        return success(list);
    }

    /**
     * 获取广告表详细信息
     */
    @GetMapping(value = "/{bId}")
    public AjaxResult getInfo(@PathVariable("bId") String bId)
    {
        return success(bannerService.selectBannerByBId(bId));
    }

    /**
     * 新增广告表
     */
    @Log(title = "广告表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Banner banner)
    {
        return success(bannerService.insertBanner(banner));
    }

    /**
     * 修改广告表
     */
    @Log(title = "广告表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Banner banner)
    {
        return toAjax(bannerService.updateBanner(banner));
    }

    /**
     * 删除广告表
     */
    @Log(title = "广告表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bId}")
    public AjaxResult remove(@PathVariable String bId)
    {
        return toAjax(bannerService.deleteBannerByBId(bId));
    }
}
